<!--
 @description 启运实际(车)
 @fileName CorePracticalShipDetail.vue
 @author zengqiongying
 @created 2021/07/29 16:38:12
-->
<template>
  <div class="dlg-page">
    <div class="dlg-title">启运实际(车)</div>
    <div class="dlg-tab">
      <div
        v-for="(item,index) in tabDisName"
        :key="index"
        class="tab-item"
        :class="{'active':tabIndex===index}"
        @click="tabIndex=index"
      >{{ item }}配送中心</div>
    </div>
    <div class="core-detail-list">
      <div class="tr">
        <div class="th">车型</div>
        <div class="th">车数</div>
        <div class="th">平均方量(m³)</div>
      </div>
      <template>
        <div v-for="(item,index) in dataList" :key="index" class="tr">
          <div class="td">{{ item.vehicleLength | filterForamtThousand }}</div>
          <div class="td">{{ item.vehicleNum | filterForamtThousand }}</div>
          <div class="td">{{ item.averVolume | filterForamtThousand }}</div>
        </div>
      </template>
      <div v-if="dataList.length===0" class="no-data">{{ loadOver?'暂无数据':'加载中' }}</div>
    </div>
  </div>
</template>

<script>
import { parseTime } from '@/utils'
import { getLogisticsCorePracticalShipDetail, getLogisticsOfficeCorePracticalShipDetail } from '@/apis/logistics'
export default {
  name: 'CoreDetail',
  props: {
    officeName: {
      type: String,
      default: ''
    },
    selectDate: {
      type: String,
      default: parseTime(new Date(), '{y}-{m}-{d}')
    }
  },
  data() {
    return {
      tabIndex: 0,
      tabDisName: ['羊马', '潜江', '清丰'],
      coreDetailData: [],
      loadOver: false // 是否加载完成
    }
  },
  computed: {
    dataList() {
      const disName = this.tabDisName[this.tabIndex]
      return this.coreDetailData.filter(v => v.disName.indexOf(disName) > -1)
    }
  },
  created() {
    this.loadOver = false
    if (this.officeName) {
      this.getOfficeDetailData()
    } else {
      this.getDetailData()
    }
  },
  methods: {
    // 订单配车
    getDetailData() {
      getLogisticsCorePracticalShipDetail(this.selectDate).then(res => {
        this.coreDetailData = res.data || []
        this.loadOver = true
      }).catch(() => {
        this.loadOver = true
      })
    },
    // 物流启运
    getOfficeDetailData() {
      const param = {
        date: this.selectDate,
        officeName: this.officeName
      }
      getLogisticsOfficeCorePracticalShipDetail(param).then(res => {
        this.coreDetailData = res.data || []
        this.loadOver = true
      }).catch(() => {
        this.loadOver = true
      })
    }
  }
}

</script>
<style lang='less' scoped>
  .dlg-title{
    // margin-bottom: 10px;
    padding:10px 0;
    line-height: 22px;
    border-bottom: 1px solid #F4F6F5;
    color: #333;
    font-size: 16px;
    letter-spacing: 1px;
    text-align: center;
    font-family: 'PFZH';
  }
  .dlg-tab{
    width: 100%;
    height: 32px;
    background: #F5F6F7;
    display: flex;
    margin-bottom: 10px;
    .tab-item{
      width: 33.33333%;
      height: 32px;
      line-height: 32px;
      font-size: 14px;
      font-family: PFZH;
      color: #888888;
      letter-spacing: 1px;
      text-align: center;
      &.active{
        color: #12B9A3;
        background: #FFFFFF;
        box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.1);
      }
    }
  }
  .core-detail-list{
    padding: 0 5px;
    font-size: 14px;
    text-align: center;
    min-height: 102px;
    .tr{
      min-height: 24px;
      margin-bottom: 10px;
      display: flex;
      align-items: center;
      color: #333333;
      letter-spacing: 1px;
    }
    .th,.td{
      width: 33.33333%;
      overflow: hidden;
    }
    .th{
      font-family: 'PFZH';
    }
  }
</style>
